//
//  PageSerie.m
//  TVCloud
//
//  Created by Clément Raussin on 12/10/12.
//  Copyright (c) 2012 Adriaenssen BVBA. All rights reserved.
//

#import "PageSerie.h"

@interface PageSerie ()

@end

@implementation PageSerie
@synthesize actusWebView;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        mySelf = self;
        

    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [nextViewButton addTarget:mySelf action:@selector(nextViewAction) forControlEvents:UIControlEventTouchUpInside];
    AppDelegate *appDelegate;
    appDelegate=(AppDelegate*)[[UIApplication sharedApplication]delegate];
    
    // on récupère le contenu du fichier html qui se trouve dans Resources de l'app et le met dans un NSString
    NSString *path = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"];
    NSString *fileText = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
    // On récupère le chemin du dossier ou se trouvent les images locales qui sont appelées dans le fichier html et on donne ses 2 infos à la webview
    NSString *path2 = [[NSBundle mainBundle] bundlePath];
    NSURL *baseURL = [NSURL fileURLWithPath:path2];
    [actusWebView loadHTMLString:fileText baseURL:baseURL];
    
    
    
    
    //[appDelegate endLoading];
    // Do any additional setup after loading the view from its nib.

    
    [self updateSelectedSegmentLabel];
    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)viewDidUnload {
    nextViewButton = nil;
    [self setActusWebView:nil];
    [super viewDidUnload];
}

- (void)nextViewAction {
    
    AppDelegate *appDelegate;
    appDelegate=(AppDelegate*)[[UIApplication sharedApplication]delegate];
    [appDelegate href:@"sted"];
    
}


- (void)updateSelectedSegmentLabel
{
    self.selectedSegmentLabel.text = [NSString stringWithFormat:@"%d", self.segmentedControl.selectedSegmentIndex];
}

- (IBAction)segmentDidChange:(id)sender
{
    [self updateSelectedSegmentLabel];
}

@end
